<?
    /* -*- Mode: PHP5; tab-width: 4; indent-tabs-mode: nil; basic-offset: 4 -*- */

    /*********************************************************
    *            --== InArch ==--
    *
    * @author Kulikov Alexey <a.kulikov@gmail.com>
    * @version n/a
    * @since 24.04.2005
    * @copyright essentialmind.com 2005
    *
    *********************************************************/
    
    /***
    * Class clientNodePage
    ****
    * This classs represents a root page of any solution
    ****
    * @package clientNodes
    * @author A Kulikov <a.kulikov@gmail.com>
    * @version n/a
    ***/
    class clientNodeRSS extends clientNode{

        /**
         * Process inputs
         * 
         * @return void 
         **/
        public function process(){
            $data = $this->db->getRow("SELECT * FROM node_rss WHERE id = ".$this->object);
            $data['title'] = $this->db->getOne("SELECT title FROM pagemap WHERE id = ".$this->reference);
            
            $pageType = (int)$this->db->getOne("SELECT id FROM datatype WHERE codeset = 'inserat'");

            //nothing
            $this->smarty->assign('data',$data);
            $this->smarty->assign('entries',$this->db->getAll("SELECT 
                                                pm.created          AS intime,
                                                date_trunc('minute',pm.created)          AS intime2,
                                                ni.title            AS title,
                                                ni.content          AS content,
                                                ni.image            AS image,
                                                ni.id               AS id,
                                                ni.price            AS price,
                                                ni.price_type       AS price_type,
                                                ni.ins_type         AS type,
                                                get_path(pm.nodeid)||pm.pageurl||'.html' AS url
                                            FROM pagemap AS pm 
                                            LEFT JOIN node_inserat AS ni ON pm.pageid = ni.id
                                            WHERE pm.pagetype = " . $pageType . "
                                            AND pm.wf_state = 1
                                            ORDER BY pm.published DESC LIMIT 10"));
           
            
            $this->smarty->display('rss.xml');
            exit;                                 
        }

        /**
         * @return void
         **/
        public function setTemplate(){
            $this->setActionTemplate('rss.xml');
        }
    
      }